package net.m510.autosurfer.aeoncard;

import java.io.File;
import java.net.URI;
import java.util.List;

import net.m510.autosurfer.common.FilePostProcess;
import net.m510.autosurfer.core.Parameters;
import net.m510.autosurfer.core.utils.AnalyzeUtils;

import org.apache.http.NameValuePair;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.FormElement;

public class AeonCardPdfDownload extends FilePostProcess {
	public AeonCardPdfDownload() {
		this(null,null,null);
	}
	
	public AeonCardPdfDownload(CloseableHttpClient client, HttpClientContext context, File dir) {
		super(client, context, dir);
	}
	
	@Override
	protected URI getUri(Document doc) {
		return URI.create(context.getTargetHost().toURI()).resolve("/NetBranch/seikyuDL.do?seikyuDLFlg=off");
	}

	@Override
	protected List<NameValuePair> getRequestParameters(Document doc) {
		FormElement form = AnalyzeUtils.getFormElementByName(doc, "seikyuDLForm");
		Parameters p = Parameters.create(form);
		return p.asNameValueList();
	}
}
